<template>
  <div class="account-root">
    <div class="account-root-item">
      <div class="root-left-item">
        <img src="~@/assets/images/logo-img.jpg" />
      </div>
      <div class="root-right-item">
        <div class="cursor-pointer corner" @click="loginToggle">
          <a-tooltip :content="tab === 'login' ? '注册' : '登录'">
            <icon-user-add :style="{ fontSize: '32px' }" v-if="tab === 'login'" />
            <icon-reply :style="{ fontSize: '32px' }" v-else />
          </a-tooltip>
        </div>
        <div class="account-form">
          <div v-if="tab === 'login'">
            <div class="logo-img-1">
              <img src="~@/assets/images/logo-img-1.png" alt="" />
            </div>
            <h3> 登录 </h3>
            <LoginForm ref="LoginFormRef" @go-register="changeGoRegister" />
          </div>
          <div v-else>
            <div class="logo-img-1">
              <img src="~@/assets/images/logo-img-1.png" alt="" />
            </div>
            <h3>注册</h3>
            <RegisterForm ref="RegisterFormRef" @back-login="changeBackLogin" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
import LoginForm from './LoginForm.vue';
import RegisterForm from './RegisterForm.vue';
import { getAppEnvConfig } from '@/utils/env';

const { VITE_GLOB_APP_TITLE } = getAppEnvConfig()

const tab = ref('login');

function changeBackLogin() {
  tab.value = 'login';
}

function changeGoRegister() {
  tab.value = 'register';
}

function loginToggle() {
  tab.value = tab.value === 'login' ? 'register' : 'login';
}
</script>

<style lang="less" scoped>
.account-root {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  background-color: #3454cd;

  &-item {
    width: 1000px;
    height: 560px;
    background: #2d8cf0;
    box-shadow: rgba(0, 0, 0, 0.2) 0 0 20px;
    //border-radius: 10px;
    overflow: hidden;
  }

  @media (max-width: 991px) {
    &-item {
      width: 500px;
    }
  }

  .root-left-item {
    position: relative;
    float: left;
    width: 50%;
    height: 100%;

    img {
      width: 100%;
      height: 100%;
      //object-fit: cover;
    }

    h3 {
      position: absolute;
      left: 0;
      top: 95px;
      width: 100%;
      text-align: center;
      color: #818181;
    }
  }

  @media (max-width: 991px) {
    .root-left-item {
      display: none;
    }
  }

  .root-right-item {
    float: left;
    position: relative;
    height: 100%;
    width: 500px;
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;

    // &::before {
    //   content: '';
    //   position: absolute;
    //   right: 0;
    //   top: 0;
    //   width: 40px;
    //   height: 40px;
    //   background: rgb(var(--primary-6));
    // }

    .corner {
      display: flex;
      justify-content: center;
      align-items: center;
      position: absolute;
      right: 0;
      top: 0;
      width: 80px;
      height: 80px;
      border-radius: 0 0 0 150%;
      background: rgb(var(--primary-6));

      svg {
        color: #fff;
        margin-right: -20px;
        margin-top: -10px;
      }
    }

    .account-form {
      width: 60%;

      h3 {
        font-size: 24px;
        margin-bottom: 20px;
      }

      .logo-img-1 {
        display: none;
        width: 290px;
        height: 78px;
        margin: 0 auto 30px;

        img {
          width: 100%;
          height: 100%;
        }
      }

      @media (max-width: 991px) {
        h3 {
          display: none;
        }

        .logo-img-1 {
          display: block;
        }
      }
    }
  }
}</style>
